#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author: KevinQi
@file: redis_handle.py
@time: 2023/12/27 1:08
@desc: 
"""
import tornado

from backend.workjob.utils.mysql_base import MysqlSqlalchemy


class BaseHandler(tornado.web.RequestHandler):

    def __int__(self):
        self.mysql_session = MysqlSqlalchemy().session

    # 配置请求头，允许跨域，否者在浏览器调用的时候报错误，同时还得加上允许Authorization字段过来
    def set_default_headers(self):
        self.set_header("Access-Control-Allow-Origin", "*")
        self.set_header("Access-Control-Allow-Headers", "Content-Type,Authorization,x-requested-with")
        self.set_header("Access-Control-Allow-Methods", "POST,GET,OPTIONS,PUT,DELETE")

    # 这个函数是必要的，有些浏览器或者测试工具在访问之前都会预先访问，你不写的话会导致出错的
    # 例如vue一般需要访问options方法
    def options(self):
        self.finish()
